package com.sys.SysSales.service.impl;

import java.util.List;

import com.sys.common.utils.DateUtils;
import com.sys.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sys.SysSales.mapper.SysSalesCustomersMapper;
import com.sys.SysSales.domain.SysSalesCustomers;
import com.sys.SysSales.service.ISysSalesCustomersService;

/**
 * 客户信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-09-26
 */
@Service
public class SysSalesCustomersServiceImpl implements ISysSalesCustomersService 
{
    @Autowired
    private SysSalesCustomersMapper sysSalesCustomersMapper;

    /**
     * 查询客户信息
     * 
     * @param customerId 客户信息主键
     * @return 客户信息
     */
    @Override
    public SysSalesCustomers selectSysSalesCustomersByCustomerId(Long customerId)
    {
        return sysSalesCustomersMapper.selectSysSalesCustomersByCustomerId(customerId);
    }

    /**
     * 查询客户信息列表
     * 
     * @param sysSalesCustomers 客户信息
     * @return 客户信息
     */
    @Override
    public List<SysSalesCustomers> selectSysSalesCustomersList(SysSalesCustomers sysSalesCustomers)
    {
        return sysSalesCustomersMapper.selectSysSalesCustomersList(sysSalesCustomers);
    }

    /**
     * 新增客户信息
     * 
     * @param sysSalesCustomers 客户信息
     * @return 结果
     */
    @Override
    public int insertSysSalesCustomers(SysSalesCustomers sysSalesCustomers)
    {
        sysSalesCustomers.setCreateTime(DateUtils.getNowDate());
        sysSalesCustomers.setUpdateTime(DateUtils.getNowDate());
        sysSalesCustomers.setCreatedBy(SecurityUtils.getUsername());
        sysSalesCustomers.setUpdatedBy(SecurityUtils.getUsername());
        return sysSalesCustomersMapper.insertSysSalesCustomers(sysSalesCustomers);
    }

    /**
     * 修改客户信息
     * 
     * @param sysSalesCustomers 客户信息
     * @return 结果
     */
    @Override
    public int updateSysSalesCustomers(SysSalesCustomers sysSalesCustomers)
    {
        return sysSalesCustomersMapper.updateSysSalesCustomers(sysSalesCustomers);
    }

    /**
     * 批量删除客户信息
     * 
     * @param customerIds 需要删除的客户信息主键
     * @return 结果
     */
    @Override
    public int deleteSysSalesCustomersByCustomerIds(Long[] customerIds)
    {
        return sysSalesCustomersMapper.deleteSysSalesCustomersByCustomerIds(customerIds);
    }

    /**
     * 删除客户信息信息
     * 
     * @param customerId 客户信息主键
     * @return 结果
     */
    @Override
    public int deleteSysSalesCustomersByCustomerId(Long customerId)
    {
        return sysSalesCustomersMapper.deleteSysSalesCustomersByCustomerId(customerId);
    }

    /**
     * 根据顾客id来查询产品数量
     */
    @Override
    public List<SysSalesCustomers> selectProductSalesAndTotalByCustomerId(Long customerId) {
        return sysSalesCustomersMapper.getProductSalesAndTotalByCustomerId(customerId);
    }
}
